package org.huel.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.huel.backend.domain.entity.LAByClass;
import org.huel.backend.domain.entity.LAByCourse;
import org.huel.backend.mapper.LAByClassMapper;
import org.huel.backend.mapper.LAByCourseMapper;
import org.huel.backend.result.Result;
import org.huel.backend.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Liweijian.
 * @Description TODO
 * @date 2024/11/28 17:13
 */
@Service
public class DataServiceImpl  implements DataService {

    @Autowired
    private LAByCourseMapper laByCourseMapper;

    @Autowired
    private LAByClassMapper laByClassMapper;

    @Override
    public Result getLACountByCourse() {
        QueryWrapper<LAByCourse> wrapper = new QueryWrapper<>();
        wrapper.select("course", "aCount", "lCount");

        List<LAByCourse> courseList = laByCourseMapper.selectList(wrapper);

        //System.out.println(courseList);

        return Result.success(courseList);
    }

    @Override
    public Result getLACountByClass() {
        QueryWrapper<LAByClass> wrapper = new QueryWrapper<>();
        wrapper.select("classId", "aCount", "lCount");

        List<LAByClass> classList = laByClassMapper.selectList(wrapper);

        //System.out.println(classList);

        return Result.success(classList);
    }
}
